import React,{Component} from 'react';
import { Switch } from 'antd';
class Soil extends Component{
    constructor(props){
        super(props);
        this.state = {}
    }
    render(){
        return(
            <>
                <div className="add_thing">
                    <div className="add_title">
                        <span>传感器设备管理</span>
                        <img src={require('../page/main/visualSystem/img/cancel.jpg')} alt=""/>
                    </div>
                    <div>
                        <ul className="params_list">
                            <li>
                                <span>艏喷信号</span>
                                <div>
                                    {
                                    this.props._this.state.shoupen===true?<span>是</span>:<span>否</span>
                                    }                                  
                                    
                                    <Switch onChange={(e)=>this.onChange(e,1)} />
                                </div>
                            </li>
                            <li>
                                <span>艏吹信号</span>
                                <div>
                                    {
                                    this.props._this.state.shouchui===true?<span>是</span>:<span>否</span>
                                    } 
                                    <Switch onChange={(e)=>this.onChange(e,2)} />
                                </div>
                            </li>
                            <li>
                                <span>冲仓信号</span>
                                <div>
                                    {
                                    this.props._this.state.chongcang===true?<span>是</span>:<span>否</span>
                                    } 
                                    <Switch onChange={(e)=>this.onChange(e,3)} />
                                </div>
                            </li>
                            <li>
                                <span>溢流信号</span>
                                <div>
                                    {
                                    this.props._this.state.yiliu===true?<span>是</span>:<span>否</span>
                                    } 
                                    <Switch onChange={(e)=>this.onChange(e,4)} />
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </>
        )                
    }    
    onChange(checked,i) {
        if(i === 1){
            if(checked){
                this.props._this.setState({
                    shoupen:true
                })
            }else{
                this.props._this.setState({
                    shoupen:false
                })
            }            
            return
        }else if(i === 2){
            if(checked){
                this.props._this.setState({
                    shouchui:true
                })
            }else{
                this.props._this.setState({
                    shouchui:false
                })
            }    
            return
        }else if(i === 3){
            if(checked){
                this.props._this.setState({
                    chongcang:true
                })
            }else{
                this.props._this.setState({
                    chongcang:false
                })
            }    
            return
        }else{
            if(checked){
                this.props._this.setState({
                    yiliu:true
                })
            }else{
                this.props._this.setState({
                    yiliu:false
                })
            }    
        }
    }
}
export default Soil;